#ifndef __TerrainDecal_H__
#define __TerrainDecal_H__

#include "Ogre.h"

/**
* A TerrainDecal is a mesh-decal that can 'wrap' itself to the terrain. It is used for arbitrarily
* projecting images/decals onto the terrain.
*/

class TerrainDecal
{
	Ogre::ManualObject* decal;
	Ogre::SceneNode* decalNode;
	Ogre::Vector2 dim;
	unsigned int res;
	Ogre::Real heightOffset;
	Ogre::RaySceneQuery* query;

public:
	Ogre::Real getHeight(Ogre::Real x, Ogre::Real z);
	TerrainDecal(const Ogre::String &name, const Ogre::String &material, const Ogre::Vector2 &dimensions, 
		const Ogre::Vector2 &position, Ogre::SceneManager* sceneMgr, Ogre::Real heightOffset = 0.5, unsigned int resolution = 4);
	
	void Init(Ogre::SceneManager* sceneManager, Ogre::String terreno_cfg, Ogre::String walk_map);

	~TerrainDecal();
	float getHeightAt(Ogre::Vector3 position);
	void moveTo(const Ogre::Vector2 &position);
	bool isWalkable(float x, float z);
	float getSizeX(void);
    float getSizeZ(void);

	void hide();

	void show();

	bool isVisible() const;

	private:
		Ogre::SceneManager* m_sceneManager;
		Ogre::Image* m_walkmap;
		float tamX, tamZ;

};

#endif